//
// UInstance.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------

package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;

public class UInstance extends UTransform {
  private long swigCPtr;

  public UInstance(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.UInstance_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(UInstance obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_UInstance(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public void getShapeAABBox(SWIGTYPE_p_NLMISC__CAABBox bbox) {
    nel3dJNI.UInstance_getShapeAABBox(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox));
  }

  public void setBlendShapeFactor(String blendShapeName, float factor, boolean dynamic) {
    nel3dJNI.UInstance_setBlendShapeFactor(swigCPtr, this, blendShapeName, factor, dynamic);
  }

  public long getNumMaterials() {
    return nel3dJNI.UInstance_getNumMaterials(swigCPtr, this);
  }

  public UInstanceMaterial getMaterial(long materialId) {
    return new UInstanceMaterial(nel3dJNI.UInstance_getMaterial(swigCPtr, this, materialId), true);
  }

  public void selectTextureSet(long id) {
    nel3dJNI.UInstance_selectTextureSet(swigCPtr, this, id);
  }

  public void changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest) {
    nel3dJNI.UInstance_changeMRMDistanceSetup(swigCPtr, this, distanceFinest, distanceMiddle, distanceCoarsest);
  }

  public void setShapeDistMax(float distMax) {
    nel3dJNI.UInstance_setShapeDistMax(swigCPtr, this, distMax);
  }

  public float getShapeDistMax() {
    return nel3dJNI.UInstance_getShapeDistMax(swigCPtr, this);
  }

  public boolean canStartStop() {
    return nel3dJNI.UInstance_canStartStop(swigCPtr, this);
  }

  public void start() {
    nel3dJNI.UInstance_start(swigCPtr, this);
  }

  public void stop() {
    nel3dJNI.UInstance_stop(swigCPtr, this);
  }

  public boolean isStarted() {
    return nel3dJNI.UInstance_isStarted(swigCPtr, this);
  }

  public float getDistMax() {
    return nel3dJNI.UInstance_getDistMax(swigCPtr, this);
  }

  public void setDistMax(float distMax) {
    nel3dJNI.UInstance_setDistMax(swigCPtr, this, distMax);
  }

  public void setCoarseMeshDist(float dist) {
    nel3dJNI.UInstance_setCoarseMeshDist(swigCPtr, this, dist);
  }

  public float getCoarseMeshDist() {
    return nel3dJNI.UInstance_getCoarseMeshDist(swigCPtr, this);
  }

  public void enableAsyncTextureMode(boolean enable) {
    nel3dJNI.UInstance_enableAsyncTextureMode(swigCPtr, this, enable);
  }

  public boolean getAsyncTextureMode() {
    return nel3dJNI.UInstance_getAsyncTextureMode(swigCPtr, this);
  }

  public void startAsyncTextureLoading() {
    nel3dJNI.UInstance_startAsyncTextureLoading(swigCPtr, this);
  }

  public boolean isAsyncTextureReady() {
    return nel3dJNI.UInstance_isAsyncTextureReady(swigCPtr, this);
  }

  public void setAsyncTextureDistance(float dist) {
    nel3dJNI.UInstance_setAsyncTextureDistance(swigCPtr, this, dist);
  }

  public float getAsyncTextureDistance() {
    return nel3dJNI.UInstance_getAsyncTextureDistance(swigCPtr, this);
  }

  public void setAsyncTextureDirty(boolean flag) {
    nel3dJNI.UInstance_setAsyncTextureDirty(swigCPtr, this, flag);
  }

  public boolean isAsyncTextureDirty() {
    return nel3dJNI.UInstance_isAsyncTextureDirty(swigCPtr, this);
  }

  public void setSliceTime(float duration) {
    nel3dJNI.UInstance_setSliceTime(swigCPtr, this, duration);
  }

  public float getSliceTime() {
    return nel3dJNI.UInstance_getSliceTime(swigCPtr, this);
  }

  public boolean supportMaterialRendering(UDriver drv, boolean forceBaseCaps) {
    return nel3dJNI.UInstance_supportMaterialRendering(swigCPtr, this, UDriver.getCPtr(drv), drv, forceBaseCaps);
  }

  public UShape getShape() {
    return new UShape(nel3dJNI.UInstance_getShape(swigCPtr, this), true);
  }

  public String getShapeName() {
    return nel3dJNI.UInstance_getShapeName(swigCPtr, this);
  }

  public void cast(UTransform object) {
    nel3dJNI.UInstance_cast(swigCPtr, this, UTransform.getCPtr(object), object);
  }

  public boolean getDefaultPos(CVector arg0) {
    return nel3dJNI.UInstance_getDefaultPos(swigCPtr, this, CVector.getCPtr(arg0), arg0);
  }

  public boolean getDefaultRotQuat(SWIGTYPE_p_NLMISC__CQuat arg0) {
    return nel3dJNI.UInstance_getDefaultRotQuat(swigCPtr, this, SWIGTYPE_p_NLMISC__CQuat.getCPtr(arg0));
  }

  public boolean getDefaultScale(CVector arg0) {
    return nel3dJNI.UInstance_getDefaultScale(swigCPtr, this, CVector.getCPtr(arg0), arg0);
  }

  public void setRelativeScale(CVector rs) {
    nel3dJNI.UInstance_setRelativeScale(swigCPtr, this, CVector.getCPtr(rs), rs);
  }

  public UInstance() {
    this(nel3dJNI.new_UInstance__SWIG_0(), true);
  }

  public UInstance(CTransformShape object) {
    this(nel3dJNI.new_UInstance__SWIG_1(CTransformShape.getCPtr(object), object), true);
  }

  public void attach(CTransformShape object) {
    nel3dJNI.UInstance_attach(swigCPtr, this, CTransformShape.getCPtr(object), object);
  }

  public void detach() {
    nel3dJNI.UInstance_detach(swigCPtr, this);
  }

  public boolean empty() {
    return nel3dJNI.UInstance_empty(swigCPtr, this);
  }
  /**
   * @todo check
   */
  public ITransformable getObjectPtr() {
    long cPtr = nel3dJNI.UInstance_getObjectPtr(swigCPtr, this);
    return (cPtr == 0) ? null : new CTransformShape(cPtr, false);
  }

}
